package com.example.mtblog.dto;


import com.example.mtblog.entity.User;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Date;

@AllArgsConstructor
@NoArgsConstructor
@Data
public class UserDTO {


    private Integer uid;

    /**
     * 用户名字
     */
    private String username;


    /**
     * 用户密码
     */
    private String password;


    /**
     * 头像
     */
    private String avatar;


    /**
     * 地址
     */
    private String address;

    /**
     * 性别
     */
    private String sex;


    /**
     * 是否是好友关系
     */
    private Boolean isFriend;

    /**
     * 用户信息
     */
    private UserInfo userInfo;

    /**
     * 用户权限
     */
    private UserPrivacy userPrivacy;
    /**
     * 生日
     */
    //插入时自动更新时间
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date birthday;


    /**
     * 用户状态  -1:删除 1:正常 0:封禁
     */
    private Integer userState;


    /**
     * 创建时间
     */
    //插入时自动更新时间
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date createTime;


    public UserDTO(User user) {
        this.uid = user.getUid();
        this.username = user.getUsername();
        this.password =user.getPassword();
        this.avatar = user.getAvatar();
        this.address = user.getAddress();
        this.sex = user.getSex();
        this.birthday = user.getBirthday();
        this.userState = user.getUserState();
        this.createTime = user.getCreateTime();
    }
}


